package com.gofaraway.service.student.leetCodeV2.双指针;

/**
 * https://leetcode.cn/problems/move-zeroes/?envType=study-plan-v2&envId=top-100-liked
 *
 * @author ChenPeng
 * @date 2025/7/6 18:18
 */
public class 移动零 {

    public void moveZeroes(int[] nums) {
        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 0) {
                nums[index++] = nums[i];
            }
        }

        //末尾补零
        while (index < nums.length) {
            nums[index++] = 0;
        }
    }
}
